from origionalLSH import *
import time

featureNum = 10  # 这里的特征可以看作minhash已经处理完，分割完成的原始数据
featureLength = 3  # 每个片段的长度

# step1: 生成特征
# print('#step1: 生成特征')
# features = []
# for i in range(featureNum):
#     temp = []
#     for j in range(featureLength):
#         temp.append(random.randint(0, 255))
#     features.append(temp)
# print(features)

# 为了方便，接下来我在不再使用随机数
features = [[3, 3, 10], [0, 4, 1], [9, 6, 7], [3, 6, 4], [5, 3, 10], [2, 9, 8], [10, 7, 2], [2, 7, 1], [4, 8, 9],
            [8, 9, 5]]

# # step2: LSH初始化
print('step2: LSH初始化')
lsh = LSH(10, 10, 12, 0.12, featureLength)
print(lsh.__dict__)

# step3: 开始训练
t_start = time.time()
lsh.train(features)
t_end = time.time()
print('训练时长%s' % (t_end - t_start))

# step4: search:
print('step4: search:')
print(features[4])
name,dist = lsh.search(features[4])
print(name)
print(features[name])
print(dist)
